home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / misc / math / libalgo.lha / algomath / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-30  |  566 b   |  38 lines

  1. /* sample program by Andreas R. Kleinert in 2000 */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. #include "algomath.h"
  7.  
  8. int main(int argc, char **argv)
  9. {
  10.  int d1,d2,r,n=16;
  11.  
  12.  am_init();
  13.  
  14.  printf("\nUSAGE: test [number]\n\n");
  15.  
  16.  if(argc < 2)
  17.   {
  18.    r = am_goldbach( 16, &d1, &d2);
  19.    printf("%d = %d + %d\n",n,d1,d2);
  20.   }else
  21.   {
  22.    n = atol(argv[1]);
  23.  
  24.    if(n & 1)
  25.     {
  26.      printf("Sorry, must be EVEN number. %d isn't even...\n\n", n);
  27.     }else
  28.     {
  29.      r = am_goldbach(n, &d1, &d2);
  30.      printf("%d = %d + %d\n\n", n, d1, d2);
  31.     }
  32.   }
  33.  
  34.  am_exit();
  35.  
  36.  exit(0);
  37. }
  38.